package com.meichis.yndms.vm;

import androidx.lifecycle.MutableLiveData;

import com.meichis.yndms.model.DataTable;
import com.meichis.yndms.model.MinStatistical;
import com.meichis.yndms.repository.manager.MinStatisticalManager;

import java.util.ArrayList;
import java.util.List;

public class MinStatisticalVm extends MyViewModel {

    private MutableLiveData<List<MinStatistical>> minStatisticalList;

    private List<DataTable> dataTableList;
    private MutableLiveData<DataTable> dataTable;


    public MutableLiveData<DataTable> getDataTable() {
        if (dataTable == null) {
            dataTable = new MutableLiveData<>();
            dataTable.setValue(getDataTableList().get(0));
        }
        return dataTable;
    }

    public List<DataTable> getDataTableList() {
        if (dataTableList == null) {
            dataTableList = new ArrayList<>();
            //时间维度： 1昨日 2本周 3本月
            dataTableList.add(new DataTable(1, "昨天"));
            dataTableList.add(new DataTable(2, "本周"));
            dataTableList.add(new DataTable(3, "本月"));
        }
        return dataTableList;
    }

    public MutableLiveData<List<MinStatistical>> getMinStatisticalList() {
        if (minStatisticalList == null) {
            minStatisticalList = new MutableLiveData<>();
        }
        return minStatisticalList;
    }

    public void getRegistSPCount() {
        MinStatisticalManager.getInstance().GetRegistSPCount(getShowDialog(),  getUserInfo().getValue().getOrgId(),getDataTable().getValue().getValue(), minStatisticalList);
    }
}
